home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20000217-20000824 / 000047_news@columbia.edu _Sat Feb 26 11:10:50 2000.msg < prev    next >
Internet Message Format  |  2020-01-01  |  4KB

  1. Return-Path: <news@columbia.edu>
  2. Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
  3.     by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id LAA07331
  4.     for <kermit.misc@watsun.cc.columbia.edu>; Sat, 26 Feb 2000 11:10:50 -0500 (EST)
  5. Received: (from news@localhost)
  6.     by newsmaster.cc.columbia.edu (8.9.3/8.9.3) id KAA24981
  7.     for kermit.misc@watsun.cc.columbia.edu; Sat, 26 Feb 2000 10:41:13 -0500 (EST)
  8. X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
  9. From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
  10. Subject: Re: Array name passed to macro as argument?
  11. Date: 26 Feb 2000 15:41:12 GMT
  12. Organization: Columbia University
  13. Message-ID: <898s6o$ocj$1@newsmaster.cc.columbia.edu>
  14. To: kermit.misc@columbia.edu
  15.  
  16. In article <897bui$l35$1@nnrp1.deja.com>,
  17. Peter Easthope  <peter_easthope@gulfnet.pinc.com> wrote:
  18. : ...
  19. : Thanks Frank.  For the programming objective which
  20. : instigated the enquiry I found a nice solution based on
  21. : redefinition of a macro within a macro.  With any luck you
  22. : will be able to examine it soon.  Your instructions about
  23. : array syntax are recorded for future reference.
  24. : Perhaps a brief discussion and comparison of syntax of
  25. : formal languages can be tolerated here.  This is for
  26. : interest and is not a criticism of Kermit.
  27. : I also program in J ...
  28. Although J is new to me, it seems indeed there are many 
  29. similarities.  Of course these come of the common needs of
  30. programmers in any language.
  31.  
  32. : Alternatively, the name of the array, rather than the
  33. : value it contains, is passed to fn this way.
  34. :   fn 'I'
  35. Kermit uses different syntax for scalars and arrays, plus
  36. there are two kinds of scalars:
  37.  
  38.   Name     Referenced      Result
  39.    \%a        \%a          Evaluated recursively
  40.    foo        \m(foo)      Evaluated one level deep
  41.  
  42. : I did not realize that MS-DOS Kermit is written in
  43. : assembler.  Wow!
  44. : ...
  45. : I have used J6 on a PC with DOS 5.0 and never encountered
  46. : a limit.  One J application was much larger than my Kermit 
  47. : application.  J6 must use extended memory or something
  48. : similar.
  49. It must be.  Or else it simply uses all of "low memory" for
  50. language purposes, whereas MS-DOS Kermit also has to fit all
  51. its file transfer, terminal emulation, character-set
  52. translation, and communications (including an entire TCP/IP
  53. stack) in the same space, and still leave space to run
  54. external commands.
  55.  
  56. : 1.  Some manipulations of an array, including transfer as
  57. : argument, can be performed without reference to components.
  58. In C-Kermit 7.0 and K95 1.1.19, we have a whole new set of
  59. array operations: CLEAR, COPY, DECLARE, DESTROY, RESIZE, SET,
  60. SHOW, SORT.  HELP ARRAY gives the details.
  61.  
  62. However, (at least) one is missing: ARRAY EQUATE.  This would
  63. have been just what you needed:
  64.  
  65.   define foo {
  66.       array equate a \%1
  67.       echo \&a[1]
  68.       ...
  69.   }
  70.  
  71. This would redirect all references to array \&a[] or its members
  72. to the argument array, which achieves the affect of call by
  73. reference.  I'll add this to the list for future releases.
  74.  
  75. Until then, if you didn't mind making a copy of the array, you
  76. could use:
  77.  
  78.   define foo {
  79.       local \&a[]
  80.       array copy \%1 a
  81.       echo \&a[1]
  82.       ...
  83.   }
  84.  
  85. But of course then any changes you made to the local array
  86. would not be reflected in the original.   This is equivalent
  87. to call by value.
  88.  
  89. Lots of other array operations are possible, but they are usually
  90. best accomplished using the tools already there.  You can see
  91. some examples in the C-Kermit script library:
  92.  
  93.   http://www.columbia.edu/kermit/ckscripts.html#oops
  94.  
  95. - Frank